﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StoreVnCore.Common
{
    /// <summary>
    /// Utility for Solution.
    /// </summary>
    public class Utility
    {
        #region Functions Utility for Numberic
        public static bool IsInteger(object obj)
        {
            try
            {
                Convert.ToInt32(obj);
                return true;
            }
            catch
            {
                return false;
            }
        }
        public static bool IsIntegerNull(object obj)
        {
            if (obj == null) return true;
            if (IsInteger(obj) && obj.ToString().Trim() == "") return true;
            if (IsInteger(obj) && obj.ToString().Trim() == "0") return true;
            return false;
        }
        public static int InitializeInteger
        {
            get
            {
                return 0;
            }
        }


        public static bool IsDouble(object obj)
        {
            try
            {
                Convert.ToDouble(obj);
                return true;
            }
            catch
            {
                return false;
            }
        }
        public static int InitializeDouble
        {
            get
            {
                return 0;
            }
        }
        #endregion

        #region Functions Utility for DateTime
        public static bool IsDateTime(object obj)
        {
            try
            {
                Convert.ToDateTime(obj);
                return true;
            }
            catch
            {
                return false;
            }
        }
        public static bool IsDateTimeNull(object obj)
        {
            if (obj == null) return true;
            if (IsDateTime(obj) && obj.ToString().Trim() == "") return true;
            if (IsDateTime(obj) && Convert.ToDateTime(obj) == DateTime.MinValue) return true;
            if (IsDateTime(obj) && obj.ToString().IndexOf("1/1/1900") > -1) return true;
            if (IsDateTime(obj) && obj.ToString().IndexOf("01/01/1900") > -1) return true;
            return false;
        }
        public static DateTime InitializeDateTime
        {
            get
            {
                return Convert.ToDateTime("01/01/1900");
            }
        }
        #endregion

        #region Functions Utility for String
        public static bool IsStringNullOrEmpty(object obj)
        {
            if (obj == null) return true;
            if (obj.ToString().Trim() == string.Empty) return true;
            if (obj.ToString().Trim() == "") return true;
            return false;
        }
        public static bool IsMultilineNullOrEmpty(object obj)
        {
            if (obj == null) return true;
            if (obj.ToString() == string.Empty) return true;
            if (obj.ToString() == "") return true;
            return false;
        }
        public static string InitializeString
        {
            get
            {
                return string.Empty;
            }
        }


        #endregion

        #region Functions Utility for Boolean
        public static bool InitializeBool
        {
            get
            {
                return false;
            }
        }
        #endregion
    }
}
